﻿using System;
namespace Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000 {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="oma", Namespace="http://producers.ehma-10000000.xtee.riik.ee/producer/ehma-10000000", Target=typeof(Oma))]
    public class OmaSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IOma clazz;
        
        public OmaSerializer(IOma clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("slotid");
            if (clazz.Slotid!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Slotid))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Slotid");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("gameplay");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "nonNegativeInteger");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdNonNegativeInteger(((decimal)(clazz.Gameplay))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("drop");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.Drop))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("coinin");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.Coinin))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("coinout");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.Coinout))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="slotid") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>oma>slotid");
                }
                clazz.Slotid = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("slotid")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>oma>slotid", Reader.LocalName);
            }
            if (Reader.LocalName=="gameplay") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>oma>gameplay");
                }
                clazz.Gameplay = new global::Xtee.Core.Schema.XsdNonNegativeInteger(Reader.ReadElementString("gameplay")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>oma>gameplay", Reader.LocalName);
            }
            if (Reader.LocalName=="drop") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>oma>drop");
                }
                clazz.Drop = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("drop")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>oma>drop", Reader.LocalName);
            }
            if (Reader.LocalName=="coinin") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>oma>coinin");
                }
                clazz.Coinin = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("coinin")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>oma>coinin", Reader.LocalName);
            }
            if (Reader.LocalName=="coinout") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>oma>coinout");
                }
                clazz.Coinout = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("coinout")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>oma>coinout", Reader.LocalName);
            }
        }
    }
}
